package com.poorstu.web;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionMapping;
import org.apache.struts.action.DynaActionForm;

import com.common.base.web.BaseAction;
import com.poorstu.manager.AdminMeg;
import com.poorstu.manager.RoleManager;
import com.poorstu.model.RoleMod;


public class AddRoleAction extends BaseAction {

	@Override
	public ActionForward execute(ActionMapping mapping, ActionForm form,
			HttpServletRequest request, HttpServletResponse response) {
		
		try{
		DynaActionForm dyaction=(DynaActionForm)form;
		String roleName=(String)dyaction.get("rolename");
		RoleMod role=new RoleMod();
		role.setRoleName(roleName);
		role.setRoleaStatus("1");
		RoleManager roleMan=(RoleManager)getBean("roleMeg");
		boolean b=roleMan.newRole(role);
		if(b){
			mapping.findForward("succaddrole");
		}
		
		}catch(Exception e){
			e.printStackTrace();
			return mapping.findForward("failure");
		}
		return mapping.findForward("failure");
	}

}
